<?php

use yii\db\Migration;

class m210222_083109_addon_expense extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%addon_expense}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT '编号'",
            'merchant_id' => "int(11) NULL DEFAULT '0'",
            'member_id' => "int(11) NOT NULL DEFAULT '0' COMMENT '用户ID'",
            'cate_id' => "int(11) NULL COMMENT '分类'",
            'amount' => "decimal(10,2) NULL COMMENT '报销金额'",
            'content' => "text NOT NULL COMMENT '内容'",
            'covers' => "text NULL COMMENT '报销凭证'",
            'log' => "json NULL COMMENT '审核日志'",
            'remind' => "int(11) NOT NULL DEFAULT '0' COMMENT '提醒方式'",
            'sort' => "int(11) NULL DEFAULT '0' COMMENT '排序'",
            'state' => "varchar(32) NULL COMMENT '工作流状态'",
            'status' => "varchar(32) NULL DEFAULT 'apply' COMMENT '状态'",
            'created_at' => "int(10) NOT NULL DEFAULT '0' COMMENT '创建时间'",
            'updated_at' => "int(10) NOT NULL DEFAULT '0' COMMENT '更新时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='报修管理'");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%addon_expense}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

